import Mock from 'mockjs' //导入mockjs
// const Random = Mock.Random;
let { data } = Mock.mock({
  data:[
    {
      'id|+1': 1,
      username: 'hlp100650',
      password: '123456',
      name:'侯亮平',
      num: '100650',
      pho:'13344445555',
      team: '侯亮平小队',
      token: '1544432',
      teamper:['张三','李四','王五','赵六'],
      membermsg: [
        {
          name: '张三',
          id: 2,
          'teeamateSex|1': ['男', '女'],
          'nation|1': ['汉族', '蒙古族', '壮族', '满族'],
          phone: '@phone',
          'join|2003058804-183058804': 1403058804,
          date: '@date(yyyy-MM-dd)',
          'age|20-60': 0, // 10-60以内的随机数，0用来确定类型
          address: '@city(true)',
          
          // addr: `${Random.province()}-${Random.city()}-${Random.county()}`,
          item: ['日常巡查'],
          'disciplines|1': ['有', '无'],
        },
       {
          name: '李四',
          id: 3,
          'teeamateSex|1': ['男', '女'],
          'nation|1': ['汉族', '蒙古族', '壮族', '满族'],
          phone: '@phone',
          'join|2003058804-183058804': 1403058804,
          date: '@date(yyyy-MM-dd)',
          'age|20-60': 0, // 10-60以内的随机数，0用来确定类型
          address: '@city(true)',
          // addr: `${Random.province()}-${Random.city()}-${Random.county()}`,
          item: ['日常巡查'],
          'disciplines|1': ['有', '无'],
       },
       {
          name: '王五',
          id: 4,
          'teeamateSex|1': ['男', '女'],
          'nation|1': ['汉族', '蒙古族', '壮族', '满族'],
          phone: '@phone',
          'join|2003058804-183058804': 1403058804,
          date: '@date(yyyy-MM-dd)',
          'age|20-60': 0, // 10-60以内的随机数，0用来确定类型
          address: '@city(true)',
          // addr: `${Random.province()}-${Random.city()}-${Random.county()}`,
          item: ['日常巡查'],
          'disciplines|1': ['有', '无'],
       },
       {
          name: '赵六',
          id: 5,
          'teeamateSex|1': ['男', '女'],
          'nation|1': ['汉族', '蒙古族', '壮族', '满族'],
          phone: '@phone',
          'join|2003058804-183058804': 1403058804,
          date: '@date(yyyy-MM-dd)',
          'age|20-60': 0, // 10-60以内的随机数，0用来确定类型
          address: '@city(true)',
          // addr: `${Random.province()}-${Random.city()}-${Random.county()}`,
          item: ['日常巡查'],
          'disciplines|1': ['有', '无'],
       },

      ],
     
    },
    {
      'id|+1': 1,
      username: 'ldk100651',
      password: '123456',
      name:'李达康',
      num: '100651',
      pho:'13344446666',
      team:  '李达康小队',
      token: '1545672',
      teamper:['张三','李四','王五','赵六'],
      membermsg: [
        {
          name: '张三',
          'teeamateSex|1': ['男', '女'],
          'nation|1': ['汉族', '蒙古族', '壮族', '满族'],
          phone: '@phone',
          'join|2003058804-183058804': 1403058804,
          date: '@date(yyyy-MM-dd)',
          'age|20-60': 0, // 10-60以内的随机数，0用来确定类型
          address: '@city(true)',
          
          // addr: `${Random.province()}-${Random.city()}-${Random.county()}`,
          item: ['日常巡查'],
          'disciplines|1': ['有', '无'],
        },
       {
          name: '李四',
          'teeamateSex|1': ['男', '女'],
          'nation|1': ['汉族', '蒙古族', '壮族', '满族'],
          phone: '@phone',
          'join|2003058804-183058804': 1403058804,
          date: '@date(yyyy-MM-dd)',
          'age|20-60': 0, // 10-60以内的随机数，0用来确定类型
          address: '@city(true)',
          // addr: `${Random.province()}-${Random.city()}-${Random.county()}`,
          item: ['日常巡查'],
          'disciplines|1': ['有', '无'],
       },
       {
          name: '王五',
          'teeamateSex|1': ['男', '女'],
          'nation|1': ['汉族', '蒙古族', '壮族', '满族'],
          phone: '@phone',
          'join|2003058804-183058804': 1403058804,
          date: '@date(yyyy-MM-dd)',
          'age|20-60': 0, // 10-60以内的随机数，0用来确定类型
          address: '@city(true)',
          // addr: `${Random.province()}-${Random.city()}-${Random.county()}`,
          item: ['日常巡查'],
          'disciplines|1': ['有', '无'],
       },
       {
          name: '赵六',
          'teeamateSex|1': ['男', '女'],
          'nation|1': ['汉族', '蒙古族', '壮族', '满族'],
          phone: '@phone',
          'join|2003058804-183058804': 1403058804,
          date: '@date(yyyy-MM-dd)',
          'age|20-60': 0, // 10-60以内的随机数，0用来确定类型
          address: '@city(true)',
          // addr: `${Random.province()}-${Random.city()}-${Random.county()}`,
          item: ['日常巡查'],
          'disciplines|1': ['有', '无'],
       },

      ],
     
    }
  ]
})
console.log(data);
Mock.mock('/user', 'post', (option) => {
  //路径与请求方式
  const { username, password } = JSON.parse(option.body) //将传递进来的数据保存
  for (let i = 0; i < data.length; i++) {
    //判断userList中是否存在该用户并且用户密码是否正确
    if (
      username ===data[i].username &&
      password ===data[i].password
    ) {
      return {
        meta: {
          msg: 'success',
          status: 200,
        },
        user:data[i]
      }
    }
  }
  return {
    meta: {
      msg: 'error',
      status: 201,
    },
  }
})

export default Mock
